(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');

ga("create", analyticsAccount, "auto");
ga("set","anonymizeIp",true);
ga("send","pageview");

// send IP version to Google Analytics
ga('send', 'event', 'InternetProtocol', ipversion, 'IP');

// send GA events for the notifications
switch(ga_notificationcode){
	/* newsletter events */
	case "EMAIL_OPTIN_SENT":
		ga('send', 'event', 'Newsletter', 'OptInSent');
		break;
	case "INVALID_OPTINTOKEN":
		ga('send', 'event', 'Newsletter', 'InvalidOptInToken');
		break;
	case "SUBSCRIPTION_SUCCESSFUL":
		ga('send', 'event', 'Newsletter', 'SubscriptionSuccessful');
		break;
	case "SUBSCRIPTION_UPDATED":
		ga('send', 'event', 'Newsletter', 'SubscriptionUpdated');
		break;
	case "SUBSCRIPTION_UPDATE_FAILED":
		ga('send', 'event', 'Newsletter', 'SubscriptionUpdateFailed');
		break;
	case "EMAIL_UPDATECONFIRM_SENT":
		ga('send', 'event', 'Newsletter', 'SubscriptionUpdateConfirmSent');
		break;
	case "EMAIL_SUBSCRIPTION_CAPTCHA_FAILURE":
		ga('send', 'event', 'Newsletter', 'SubscriptionCaptchaFailure');
		break;
	case "UNSUBSCRIBE_SUCCESSFUL":
		ga('send', 'event', 'Newsletter', 'UnsubscribeSuccessful');
		break;
	case "UNSUBSCRIBE_FAILED":
		ga('send', 'event', 'Newsletter', 'UnsubscribeFailed');
		break;
	case "UNSUBSCRIBE_REQUEST_SUCCESSFUL":
		ga('send', 'event', 'Newsletter', 'UnsubscribeRequestSuccessful');
		break;
	case "UNSUBSCRIBE_REQUEST_FAILED":
		ga('send', 'event', 'Newsletter', 'UnsubscribeRequestFailed');
		break;

	/* contact form events */
	case "CONTACT_CAPTCHA_FAILED":
		ga('send', 'event', 'Contact', 'ContactCaptchaFailed');
		break;
	case "CONTACT_REQUEST_FAILED":
		ga('send', 'event', 'Contact', 'ContactRequestFailed');
		break;
	case "CONTACT_REQUEST_SENT":
		ga('send', 'event', 'Contact', 'ContactRequestSent');
		break;

	/* comment events */
	case "COMMENT_POSTED":
		ga('send', 'event', 'Comment', 'CommentPosted', ga_article_title);
		break;
	case "COMMENT_DELETED":
		ga('send', 'event', 'Comment', 'CommentDeleted', ga_article_title);
		break;
}

// send the authentication and comment events to GA
if(ga_is_new_user=="1"){
	ga('send', 'event', 'Authentication', 'LoggedIn', ga_auth_provider);
}if(ga_is_logged_out=="1"){
  	ga('send', 'event', 'Authentication', 'LoggedOut', ga_auth_provider);
}

/* track authentication events */
function authtrack(eventName,eventAuthProvider){
	ga('send', 'event', 'Authentication', eventName, eventAuthProvider);
}

/* sends a click event to google analytics */
function linktrack(category,linkvalue){
	ga('send','event',category,'Click',linkvalue);
}